import observe from "./observe.js"

export function defineReactive(target, key, val) {
    if (arguments.length == 2) {
        val = target[key]
    }
    observe(val)
    Object.defineProperty(target, key, {
        get() {
            return val
        },
        set(newValue) {
            if (val === newValue) return
            val = newValue
            observe(newValue)
        }
    })
}